<%@ Page Language="C#" MasterPageFile="~/Frame.Master" AutoEventWireup="true" CodeBehind="EMPForm.aspx.cs"
    Inherits="BaseSystem._System.EMPForm" Title="Emp Page" %>

<%@ Register Assembly="Auto.WebControls" Namespace="Auto.WebControls" TagPrefix="ComboBox" %>
<%@ Register Src="UserControl/ucDivEmp.ascx" TagName="ucDivEmp" TagPrefix="uc1" %>
<%@ Register Src="UserControl/ucDDLDivision.ascx" TagName="ucDDLDivision" TagPrefix="uc4" %>
<%--<%@ Register Src="UserControl/ucDateTextBox.ascx" TagName="ucDateTextBox" TagPrefix="uc2" %>--%>
<%@ Import Namespace="Auto.Data.HumanResource" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentMain" runat="server">
    <script src="../_System/Script/Common.js" type="text/javascript"></script>
    <div class="TitleDivStyle">
        <asp:Label ID="Label1" runat="server" Text="<%$ Resources:Base,AddEmpBasic %>"></asp:Label></div>
    <table>
        <tr>
            <td valign="top" class="borderStyle">
                <div id="TreeDiv" class="overStyle">
                    <uc1:ucDivEmp ID="UcDivEmp1" runat="server" />
                </div>
            </td>
            <td valign="top" style="padding: 2px;">
                <table align="left" class="borderStyle">
                    <tr>
                        <td class="table_body">
                            <%=Resources.Base.EmpID %>
                        </td>
                        <td class="table_none">
                            <asp:TextBox ID="txtEmpID" runat="server" CssClass="textcommon"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtEmpID"
                                Display="dynamic" ErrorMessage="Emp ID could not be blank" SetFocusOnError="True"></asp:RequiredFieldValidator><asp:RegularExpressionValidator
                                    ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtEmpID"
                                    Display="dynamic" ErrorMessage="Emp ID length must between 1 and 20" SetFocusOnError="True"
                                    ValidationExpression=".{1,20}"></asp:RegularExpressionValidator>
                        </td>
                        <td class="table_body">
                            <%=Resources.Base.PersonID%>
                        </td>
                        <td class="table_none" nowrap="nowrap">
                            <asp:TextBox ID="txtPersonID" runat="server" CssClass="textcommon"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="table_body">
                            <%=Resources.Base.EmpName %>
                        </td>
                        <td class="table_none">
                            <asp:TextBox ID="txtName" runat="server" CssClass="textcommon"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtName"
                                ErrorMessage="Emp Name could not be blank" Display="dynamic" SetFocusOnError="True"></asp:RequiredFieldValidator>
                            <asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server" ControlToValidate="txtName"
                                ErrorMessage="Emp Name length must between 1 and 20" ValidationExpression=".{1,50}"
                                Display="dynamic" SetFocusOnError="True"></asp:RegularExpressionValidator>&nbsp;
                        </td>
                        <td class="table_body" nowrap="nowrap">
                            <%=Resources.Base.OfficePhone%>
                        </td>
                        <td class="table_none" nowrap="nowrap">
                            <asp:TextBox ID="txtOfficePhoneExt" runat="server" CssClass="textcommon"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="table_body">
                            &nbsp;<%=Resources.Base.Email%>
                        </td>
                        <td class="table_none">
                            <asp:TextBox ID="txtEmail" runat="server" CssClass="textcommon"></asp:TextBox>
                        </td>
                        <td class="table_body" nowrap="nowrap">
                            <%=Resources.Base.LevelNO%>
                        </td>
                        <td class="table_none" nowrap="nowrap">
                            <asp:TextBox ID="txtLevelNO" runat="server" CssClass="textcommon"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="table_body">
                            &nbsp;<%=Resources.Base.CardNO%>
                        </td>
                        <td class="table_none">
                            <asp:TextBox ID="txtCardNO" runat="server" CssClass="textcommon"></asp:TextBox>
                        </td>
                        <td class="table_body" nowrap="nowrap">
                            <%=Resources.Base.BirthDay%>
                        </td>
                        <td class="table_none" nowrap="nowrap">
                            <%--<uc2:ucDateTextBox ID="UcDateTextBox1" runat="server" />--%>
                            <ComboBox:DateTextBox ID="UcDateTextBox1" runat="server"></ComboBox:DateTextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="table_body">
                            <%=Resources.Base.Sex%>
                        </td>
                        <td class="table_none">
                            <asp:DropDownList ID="ddlSex" runat="server">
                                <asp:ListItem Value="true" Text="<%$ Resources:Base,Male%>"></asp:ListItem>
                                <asp:ListItem Value="false" Text="<%$ Resources:Base,Female%>"></asp:ListItem>
                            </asp:DropDownList>
                        </td>
                        <td class="table_body" nowrap="nowrap">
                            &nbsp;<%=Resources.Base.MaritalStatus%>
                        </td>
                        <td class="table_none" nowrap="nowrap">
                            <asp:DropDownList ID="ddlMarried" runat="server">
                                <asp:ListItem Value="true" Text="<%$ Resources:Base,Married%>"></asp:ListItem>
                                <asp:ListItem Value="false" Text="<%$ Resources:Base,Unmarried%>"></asp:ListItem>
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td class="table_body">
                            <%=Resources.Base.Note%>
                        </td>
                        <td class="table_none">
                            <asp:TextBox ID="txtNote" runat="server" CssClass="textcommon"></asp:TextBox>
                        </td>
                        <td class="table_body" nowrap="nowrap">
                            <%=Resources.Base.CopyToUser %>
                        </td>
                        <td class="table_none" nowrap="nowrap">
                            <asp:CheckBox ID="chkCopyToUser" runat="server" Text="<%$Resources:Base,CopyToUser %>" />
                        </td>
                    </tr>
                    <tr>
                        <td class="table_body" nowrap="nowrap" style="height: 22px">
                            <%=Resources.Base.DivID%>
                        </td>
                        <td class="table_none" nowrap="nowrap" colspan="3" style="height: 22px">
                            <div class="OperateStyle" style="float: left;">
                                <uc4:ucDDLDivision ID="UcDDLDivision1" runat="server" />
                            </div>
                            <div style=" visibility:hidden;">
                                <br />
                                <%--                                <input type="button" class="button_bak" onclick="Display('tr0',this)" value="<%=Resources.Base.Auxiliary %>" />--%>
                                <a href="#" onclick="Display('<%=tr0.ClientID %>',this)">
                                    <%=Resources.Base.Auxiliary %></a>
                            </div>
                        </td>
                    </tr>
                    <tr id="tr0" style="display: none;" runat="server">
                        <td class="table_body" nowrap="nowrap">
                            <%=Resources.Base.Division %>
                        </td>
                        <td class="table_none" nowrap="nowrap" colspan="3">
                            <asp:TextBox ID="txtEmpDivs" runat="server" BackColor="Silver" TextMode="MultiLine"
                                Width="328px"></asp:TextBox>
                            <%--                            <input type="button" class="button_bak" value="<%=Resources.Base.GetDivs %>" onclick="newWin = window.open('SearchDiv.aspx?TextBoxID=<%=txtEmpDivs.ClientID%>','_blank','directories=0, height=600, left=0, location=0, resizable=1, menubar=0, scrollbars=1, status=0, titlebar=0, toolbar=0, top=0, width=500');" />--%>
                            <a href="#" class="orgAdd" onclick="newWin = window.open('SearchDiv.aspx?TextBoxID=<%=txtEmpDivs.ClientID%>','_blank','directories=0, height=600, left=0, location=0, resizable=1, menubar=0, scrollbars=1, status=0, titlebar=0, toolbar=0, top=0, width=500');">
                                <%=Resources.Base.GetDivs %></a> <a href="javascript:void(0)" class="orgClear" onclick="ClearValue('<%=txtEmpDivs.ClientID %>');">
                                    <%=Resources.Base.Clear%></a>
                        </td>
                    </tr>
                    <tr height="30px">
                        <%--                                                         BORDER-RIGHT: #000000 2px solid; BORDER-TOP: #adbac9 2px solid; BORDER-LEFT: #adbac9 2px solid; COLOR: #ffffff; BORDER-BOTTOM: #000000 2px solid; BACKGROUND-COLOR: #637994
                                                             BORDER-RIGHT: #002200 2px solid; BORDER-TOP: #a6c1df 2px solid; BORDER-LEFT: #a6c1df 2px solid; COLOR: #ffffff; BORDER-BOTTOM: #002200 2px solid; BACKGROUND-COLOR: #3a6ea5       
                                                             BORDER-RIGHT: #000000 2px solid; BORDER-TOP: #d0ecff 2px solid; BORDER-LEFT: #d0ecff 2px solid; COLOR: #ffff00; BORDER-BOTTOM: #000000 2px solid; BACKGROUND-COLOR: #0099ff 
                                                                                                                                                                                                                               #63b8ff   #8db6cd
                        --%>
                        <td nowrap="nowrap" colspan="4" style="border-right: #a2bfe9 2px solid; border-top: #edf1f8 2px solid;
                            border-left: #edf1f8 2px solid; border-bottom: #a2bfe9 2px solid; background-color: #d7e3f6">
                            <%--                            <%=Resources.Base.SecurityControl %>--%>
                            <asp:Label ID="Label2" runat="server" Text="<%$Resources:Base,SecurityControl %>"
                                Font-Size="14px" Font-Bold="true" ForeColor="#0066CC"></asp:Label>:
                            <%--                            <input type="button" value="<%=Resources.Base.Collapse %>" name="Collapse" id="btnSecurity"
                                class="button_bak" onclick="SecurityInfo(this);" />--%>
                            <a href="#" id="btnSecurity" name="Collapse" onclick="SecurityInfo(this);">
                                <%=Resources.Base.Collapse %></a>
                        </td>
                    </tr>
                    <tr id="tr1">
                        <td class="table_body" nowrap="nowrap">
                            <%=Resources.Base.RoleID %>
                        </td>
                        <td class="table_none" nowrap="nowrap" colspan="3">
                            <asp:TextBox ID="txtRoles" runat="server" BackColor="Silver" TextMode="MultiLine"
                                Width="328px"></asp:TextBox>
                            <%--                            <input type="button" class="button_bak" value="<%=Resources.Base.GetRoles %>" onclick="GetRoles();" />--%>
                            <a href="#" onclick="GetRoles();" class="orgAdd">
                                <%=Resources.Base.GetRoles %></a> <a href="javascript:void(0)" class="orgClear" onclick="ClearValue('<%=txtRoles.ClientID %>');">
                                    <%=Resources.Base.Clear%></a>
                        </td>
                    </tr>
                    <tr id="tr2" height="30px" style="visibility: hidden">
                        <%--BORDER-RIGHT: #a2bfe9 2px solid; BORDER-TOP: #edf1f8 2px solid; BORDER-LEFT: #edf1f8 2px solid; BORDER-BOTTOM: #a2bfe9 2px solid; BACKGROUND-COLOR:#d7e3f6--%>
                        <td nowrap="nowrap" colspan="4" style="border-right: #a2bfe9 2px solid; border-top: #edf1f8 2px solid;
                            border-left: #edf1f8 2px solid; border-bottom: #a2bfe9 2px solid; background-color: #d7e3f6">
                            <%--<%=Resources.Base.Access %>:--%>
                            <asp:Label ID="Label3" runat="server" Text="<%$Resources:Base,Access %>" Font-Size="14px"
                                Font-Bold="true" ForeColor="#0066CC"></asp:Label>:
                            <asp:DropDownList ID="ddlAccess" runat="server">
                                <asp:ListItem>-- --</asp:ListItem>
                                <asp:ListItem Value="1" Text="<%$Resources:Base,EmpInfo %>"></asp:ListItem>
                                <asp:ListItem Value="2" Text="<%$Resources:Base,DivInfo %>"></asp:ListItem>
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr id="tr3" style="display: none;" runat="server">
                        <td class="table_body" nowrap="nowrap">
                            <span id="accessInfo"></span>
                        </td>
                        <td class="table_none" nowrap="nowrap" colspan="3" valign="top">
                            <asp:TextBox ID="txtAccessInfo" runat="server" BackColor="Silver" TextMode="MultiLine"
                                Width="328px"></asp:TextBox>
                            <%--                            <input id="btnGetAccessInfo" class="button_bak" onclick="GetAccessInfo()" type="button"
                                value="button" />--%>
                            <a href="#" id="btnGetAccessInfo" onclick="GetAccessInfo()" runat="server" class="orgAdd">
                            </a><a href="javascript:void(0)" class="orgClear" onclick="ClearValue('<%=txtAccessInfo.ClientID %>');">
                                <%=Resources.Base.Clear%></a>
                        </td>
                    </tr>
                    <tr>
                        <td class="table_none" colspan="4" style="text-align: center;">
                            <asp:Button ID="btnAdd" runat="server" CssClass="button_bak" OnClick="btnAdd_Click"
                                Text="<%$Resources:Base,Add %>" />
                            <asp:Button ID="btnUpdate" runat="server" CssClass="button_bak" OnClick="btnUpdate_Click"
                                Text="<%$Resources:Base,Modify %>" Visible="False" />
                            <input type="reset" class="button_bak" value="<%=Resources.Base.Reset %>" />
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    <asp:HiddenField ID="hfRole" runat="server" />
    <script type="text/javascript" src="Script/Common.js"></script>
    <script type="text/javascript">

        //Init Security Control Display State
        window.onload = function () {
            var update = document.getElementById('<%=btnUpdate.ClientID %>');
            if (update != null) {
                TableRowDisplay(true);
                document.getElementById("btnSecurity").name = "Collapse";
                document.getElementById("btnSecurity").value = "Collapse";
            }
            else {
                TableRowDisplay(false);
                document.getElementById("btnSecurity").name = "Expand";
                document.getElementById("btnSecurity").value = "Expand";
            }
            var ddlAccesss = document.getElementById('<%=ddlAccess.ClientID %>');
            var ddlAccessselectedValue = ddlAccesss.options[ddlAccesss.selectedIndex].value;
            SetAccessInfo(ddlAccessselectedValue);
        }
        //Init Security Control Display State

        //Security Info
        function SecurityInfo(btnID) {

            if (btnID.name == "Expand") {
                TableRowDisplay(true);
                btnID.name = "Collapse";
                btnID.value = '<%=Resources.Base.Collapse %>';
            }
            else {
                TableRowDisplay(false);
                btnID.name = "Expand";
                btnID.value = '<%=Resources.Base.Expand %>';
            }

        }
        function TableRowDisplay(obj) {

            var displayState = obj ? "none" : "block";
            for (var i = 1; i < 4; i++) {
                if (i == 3 && AccessInfoCurrentValue() == "-- --") {
                    continue;
                }
                var domObject = document.getElementById("tr" + i);
                domObject.style.display = displayState;
                Display("tr" + i, this);
            }
        }
        //Security Info


        //Role Info
        function SetRole(roleText, roleValue) {
            document.getElementById('<%=txtRoles.ClientID %>').value = roleText.replace(/<BR>/g, "\n");
            document.getElementById('<%=hfRole.ClientID %>').value = roleValue;
        }
        var rolesInfo;
        function GetRoles() {
            if (rolesInfo == null || rolesInfo.closed) {
                rolesInfo = window.open('SearchRoles.aspx?TextBoxID=<%=txtRoles.ClientID%>', '_blank', 'directories=0, height=600, left=0, location=0, resizable=1, menubar=0, scrollbars=1, status=0, titlebar=0, toolbar=0, top=0, width=500');
            }
            else {
                rolesInfo.focus();
            }
        }


        //Role Info


        // Emp Info
        function SetEmpValue(value) {
            document.getElementById('<%=txtAccessInfo.ClientID %>').value = value;
        }
        // Emp Info


        //Access Info
        function AccessInfoCurrentValue() {
            var ddlAccesss = document.getElementById('<%=ddlAccess.ClientID %>');
            var ddlAccessselectedValue = ddlAccesss.options[ddlAccesss.selectedIndex].value;
            return ddlAccessselectedValue;
        }
        var accessInfo;
        function GetAccessInfo() {
            if (accessInfo == null || accessInfo.closed) {
                var ddlAccessselectedValue = AccessInfoCurrentValue();
                if (ddlAccessselectedValue == "2") {
                    accessInfo = window.open('SearchDiv.aspx?TextBoxID=<%=txtAccessInfo.ClientID%>', '_blank', 'directories=0, height=600, left=0, location=0, resizable=1, menubar=0, scrollbars=1, status=0, titlebar=0, toolbar=0, top=0, width=500');
                }
                else if (ddlAccessselectedValue == "1") {
                    accessInfo = window.open('SearchEmp.aspx', '_blank', 'directories=0, height=600, left=0, location=0, resizable=1, menubar=0, scrollbars=1, status=0, titlebar=0, toolbar=0, top=0, width=500');
                }
            }
            else {
                accessInfo.focus();
            }
        }

        function AccessInfoState(obj) {
            var domObject = document.getElementById('<%=tr3.ClientID %>');
            switch (obj) {
                case "1":
                case "2":
                    domObject.style.display = "";
                    domObject.display = "table-row";
                    break;
                default: domObject.style.display = "none"; break;
            }
        }

        function SetAccessInfo(obj) {
            var accessInfoValue = document.getElementById("accessInfo");
            var btnGetAccessInfo = document.getElementById('<%=btnGetAccessInfo.ClientID %>');

            switch (obj) {
                case "1": accessInfoValue.innerHTML = btnGetAccessInfo.innerHTML = '<%=Resources.Base.EmpInfo %>'; break;
                case "2": accessInfoValue.innerHTML = btnGetAccessInfo.innerHTML = '<%=Resources.Base.DivInfo %>'; break;
                default: accessInfoValue.innerHTML = btnGetAccessInfo.innerHTML = ""; break;
            }
            AccessInfoState(obj);
        }
        //Access Info

        //    function adjustSize()
        //        {
        //            var setheight=document.documentElement.offsetHeight-34;
        //            if(setheight>0)
        //            {
        //                document.getElementById("TreeDiv").style.height=setheight+"px";
        //               
        //            }
        //            
        //        }

        //        window.onload=function()
        //        {
        //            adjustSize();
        //        }
        //        window.onresize=function()
        //        {
        //            adjustSize();
        //        }

        window.onload = function () {
            setHeight("TreeDiv", -34);
        }
        window.onresize = function () {
            setHeight("TreeDiv", -34);
        }
    </script>
</asp:Content>
